package mygang.controller;

import javax.annotation.Resource;
import mygang.singleton.Settings;
import mygang.singleton.Statistic;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
 */
@Controller
public class DecoratorController extends AbstractController {
    
    @Resource(name="sessionRegistry")
    private SessionRegistryImpl sessionRegistry;
    
    @RequestMapping("/decorator")
    public ModelAndView decorator() {
        ModelAndView model = new ModelAndView("decorator");
        
        Statistic statistic = Statistic.getInstance();
        model.addObject("guestNumber", statistic.getAllUsersNumber()-statistic.getOnlineUsersNumber());
        model.addObject("userNumber", statistic.getOnlineUsersNumber());
        
        model.addObject("appVersion", Settings.getInstance().getSystemSettingByName("Version").getValue());
        return model;
    }
}